package org.huangrui.javase.api;

/**
 * @Author hr
 * @Create 2025-11-07 11:52
 **/
public class T04StringReverse {
    public static void main(String[] args) {
        String srcStr = "尚硅谷Flink";
        StringBuilder builder = new StringBuilder(srcStr);
        builder.reverse();
        String destStr = builder.toString();
        System.out.println("反转前：" + srcStr);
        System.out.println("反转后：" + destStr);

        System.out.println("=========================");
        char[] charArray = srcStr.toCharArray();
        for(int left=0,right=charArray.length-1; left<right; left++,right--){
            char temp = charArray[left];
            charArray[left] = charArray[right];
            charArray[right] = temp;
        }
        String result = new String(charArray);
        System.out.println("反转前：" + srcStr);
        System.out.println("反转前：" + result);
    }
}
